﻿using System;
using System.Collections.Generic;
using System.Text;
using OT.Module.Model;
using OT.Module.DAL;
using OT.Common;
using OT.Dev;

using DevExpress.Xpo;
using System.ComponentModel;

namespace OT.Module.BLL
{
    [DataObject()]
    public class OrderDetail_BLL : BaseBLL<OrderDetail, OrderDetail_DAL>
    {
        public OrderDetail_BLL(Session xpo)
        {
            XpoSession = xpo;
        }

        #region DataObject Method

        // 与表格密切相关的数据处理

        #region Select
        [DataObjectMethod(DataObjectMethodType.Select)]
        public XPCollection<OrderDetail> Select(string orderId)
        {
            return new OrderDetail_DAL().GetByOrder(XpoSession, orderId);
        }

        #endregion

        #region Insert

        [DataObjectMethod(DataObjectMethodType.Insert)]
        public void Insert(OrderDetail entity)
        {
            entity.ID = CommonService.ReturnMax();
            entity.Save();
        }

        #endregion

        #region Update

        [DataObjectMethod(DataObjectMethodType.Update)]
        public void Update(OrderDetail entity, OrderDetail original_entity)
        {
            entity.Save();
        }

        #endregion

        #region _CheckDelete

        override public bool _CheckDelete(string id, ref string error)
        {
            // TODO:作删除校验时，根据定义的表间关系自动判断是否允许删除，可排除需要关联删除的表间关系
            // 作删除时，根据定义的关联删除关系进行删除

            // 要检查数据能否被删除

            return true;
        }

        #endregion

        #endregion

   }
}
